﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using bi4homev3.Entidades;
using bi4homev3.Logica;

namespace bi4homev3.Paginas
{
    public partial class AgregarCompra : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {


        }

        protected void addproducto_Click(object sender, EventArgs e)
        {
           
            Compra co = new Compra();
            Detalle item = new Detalle();
            item.Cantidad = Convert.ToInt32(this.TextBox5.Text);
            item.Preciounitario = Convert.ToDouble(this.TextBox6.Text);
            item.Producto = Convert.ToInt32(this.DropDownList1.Text);
            item.Factura = Convert.ToInt32(Session["factura"]);
            item.User = (string)(Session["usuario"]);
            AccionesCompra crea = new AccionesCompra(co);
            crea.insertardetalle(item);
            this.TextBox5.Text = " ";
            this.TextBox6.Text = " ";
            
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Compra com = new Compra();
            com.Numfactura = Convert.ToInt32(this.TextBox4.Text);
            com.Local = Convert.ToInt32(this.DropDownList3.Text);
            com.Iva = Convert.ToInt32(this.TextBox2.Text);
            com.Montototal = Convert.ToDouble(this.TextBox1.Text);
            com.Fecha = this.fecha1.Text;
            Session["factura"] = Convert.ToInt32(this.TextBox4.Text);    
            com.Usuario = (string)(Session["usuario"]);
            AccionesCompra crea = new AccionesCompra(com);
            crea.insertar();
            this.Button1.Visible = false;
            this.RESPUESTA.Text = "Hacer click en siguiente para continuar";
        }

    }
}
